////////////////////////////////////////////////////////////////////////////////
//
//  FLYING KIWI BV
//  Copyright 2010 Flying Kiwi BV
//  All Rights Reserved.
//
//  NOTICE: Flying Kiwi permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
package plantool.display.windows.objects {
	//--------------------------------------------------------------------------
	//  Imports
	//--------------------------------------------------------------------------
	import kiwi.display.DisplayObject;
	
	import plantool.modules.users.windows.objects.UserListWindowUserRow;
	
	
	//--------------------------------------------------------------------------
	//  [Metadata (Events, Style, Effects etc)]
	//--------------------------------------------------------------------------
	
	//--------------------------------------------------------------------------
	//  Class declaration
	//--------------------------------------------------------------------------
	public class WindowRowContainer extends DisplayObject {
		//--------------------------------------------------------------------------
		//Class constants
		//--------------------------------------------------------------------------
		
		//--------------------------------------------------------------------------
		//Class variables
		//--------------------------------------------------------------------------
		private var _rows:Vector.<WindowRow>	= new Vector.<WindowRow>();
		
		//--------------------------------------------------------------------------
		//Class properties
		//--------------------------------------------------------------------------
		public override function get height():Number {
			//calculate height
			var h:Number = 0;
			for each (var row:WindowRow in _rows) {
				h += row.height;
			}
			
			//return height
			return h;
		}
		
		//--------------------------------------------------------------------------
		//Constructor and Destructor
		//--------------------------------------------------------------------------
		public function WindowRowContainer() {
			super();
		}
		
		public override function dispose():void {
			//remove all rows
			removeAll();
			
			//unset list
			_rows = null;
		}
		
		//--------------------------------------------------------------------------
		//Class methods
		//--------------------------------------------------------------------------
		public function addRow(row:WindowRow):void {
			//add the row
			row.y = height;
			_rows.push(addChild(row));
		}
		
		public function removeAll():void {
			//remove all rows
			while (_rows.length > 0) {
				var row:WindowRow = _rows.pop();
				row.dispose();
				row = null;
			}
		}
	}
}